package com.sdhs.web.controller.system;

import com.sdhs.common.core.domain.R;
import com.sdhs.common.core.domain.model.FinanceBody;
import com.sdhs.common.core.domain.model.HrLeaveBody;
import com.sdhs.framework.web.service.SysPublicService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "公共数据")
@RestController
@RequestMapping("/public")
public class SysPublicController {

    @Autowired
    private SysPublicService sysPublicService;

    /**
     * 财务数据
     * @param finance
     * @return
     */
    @PostMapping("/finance")
    public R<String> finance(@RequestBody FinanceBody finance)
    {
        sysPublicService.addFinance(finance);
        return R.ok("ok");
    }


    /**
     * 请假数据
     * @param hrLeave
     * @return
     */
    @PostMapping("/hrLeave")
    public R<String> hrLeave(@RequestBody List<HrLeaveBody> hrLeave){
        for(HrLeaveBody hr:hrLeave){
            sysPublicService.addHrLeave(hr);
        }
        return R.ok("ok");
    }
}
